﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using UnityEngine;

public class _26 : MonoBehaviour
{
    public List<Company> companies = new List<Company>() 
    {
        new Company(){CompanyID=0,Name="Micro" },
        new Company(){CompanyID=1,Name="Sun" }
    };

    public List<PersonA> people = new List<PersonA>()
    {
        new PersonA(){Name="Mike",CompanyID=1 },
        new PersonA(){Name="Rose",CompanyID=0 },
        new PersonA(){Name="Steve",CompanyID=1 }
    };

    public static List<Student> listStudent = new List<Student>();
    // Start is called before the first frame update
    void Start()
    {
        //var 可以接受临时定义的类型
        var personWithCompanyList = from person in people join company in companies on person.CompanyID equals company.CompanyID select new { PersonName = person.Name, CompanyName = company.Name };
        foreach (var item in personWithCompanyList)
        {
            Debug.LogErrorFormat("{0}", item.ToString());
        }
    }

    // Update is called once per frame
    void Update()
    {

    }
}

public class PersonA
{
    public string Name { get; set; }
    public int CompanyID { get; set; }
}

public class Company
{
    public int CompanyID { get; set; }
    public string Name { get; set; }
}


